import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = 'MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDSVuQA+mr/H80ZjGxXabjh196J' +
  'SmOEuGkWxEdybvqxMfAE5KMTvC5nHMR1FexwCYP6qpKasxZzIUcht5JRVGBtsbxf' +
  'teIHNA9xTW8K90ouJu9OD/azA4CZfqc58yQ/JLQ5ZYsggeARrerCT1a9bT/C7iBl' +
  '6CFXMw5IBfU5tXL4hwIDAQAB'

const privateKey = 'MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBANJW5AD6av8fzRmM' +
  'bFdpuOHX3olKY4S4aRbER3Ju+rEx8ATkoxO8LmccxHUV7HAJg/qqkpqzFnMhRyG3' +
  'klFUYG2xvF+14gc0D3FNbwr3Si4m704P9rMDgJl+pznzJD8ktDlliyCB4BGt6sJP' +
  'Vr1tP8LuIGXoIVczDkgF9Tm1cviHAgMBAAECgYBR8cAKEYU1t3H0Dhz3QRzh/3OX' +
  'EQAMaLuoPveGwW2xMr9LaLePrLR3P2HaK5xdWZetRF6xHiwU1lYb8KR0Qub9n8S7' +
  'kygLiVG9M1f1fULPLCdOORI8JzSn4omeWctsCnda3bjEty12mQNO4TSjZMTEDkZW' +
  'jK6X3CnwEJWeDvXQQQJBAP3FQSfUCfzoSVFHtGwJA8l6BNQBAd50U8MXHdVDLPS1' +
  '10AQKhNzhpmXZDY3cQXcn9ogClNzU9wHbIeS58+KaskCQQDUL/T3LXxhK/vbYAAP' +
  '4kTiyZs1TCY9yRpitj4DOw08Rbg0SIY2u/n9PstDUbTTwOXYVsdv4/2yiCiX3/y/' +
  'AaDPAkEArespO1WbvsOns9fTtBL9kHBarL0//ah124eVP5p5TgDt048AdzI+tjbG' +
  'TE303NKWj1RUH1szxuEjpUquKlOv2QJBAKvGUxrTgPCticvT0NkLBVdPfM3N4tt7' +
  '9VdaT6OP56wWiQQSfkzLKpsgfa7281vFuozD29qyCIzCe5JP6y26JLMCQQCLX46u' +
  '6Yl8tzHM/DaIBgEwOwBLBDJy++qPCysi8uFTcjyZW4ochSSLbHa+iW6H+23YD+oj' +
  'Uo+4tnTsdM2q89WM'

// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}

